﻿using LJX.SmartPark.Common.ResponseOutput;
using LJX.SmartPark.Domain.IotInfo;
using LJX.SmartPark.Domain.IotInfo.Large;
using LJX.SmartPark.Service.IotInfo;
using LJX.SmartPark.Service.IotInfo.Dto;
using LJX.SmartPark.Service.IotInfo.Large;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace LJX.SmartPark.WebApi.Controllers.IotInfo
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "IotInfo")]
    public class IotInfoController : ControllerBase
    {
        //三色灯
        private readonly ITricolourLightServeice _TricolourLight;

        //三色灯日志
        private readonly ITricolourLightLogServeice _TricolourLightLog;

        //大屏设备
        private readonly ILargeScreenServeics _LargeScreen;

        //OLED大屏
        private readonly IOledScreenService _oledScreenService;

        //OLED大屏日志
        private readonly IOledScreenLogService _oledScreenLogService;

        public IotInfoController(ITricolourLightServeice tricolourLight, ITricolourLightLogServeice tricolourLightLog, ILargeScreenServeics largeScreen, IOledScreenService oledScreenService, IOledScreenLogService oledScreenLogService)
        {
            _TricolourLight = tricolourLight;
            _TricolourLightLog = tricolourLightLog;
            _LargeScreen = largeScreen;
            _oledScreenService = oledScreenService;
            _oledScreenLogService = oledScreenLogService;
        }



        #region 三色灯

        /// <summary>
        /// 获取总条数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetCount()
        {
            return _TricolourLight.GetCount();
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddTricolourLight(TricolourLight input)
        {
            var result = _TricolourLight.PostAddTricolourLight(input);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteTricolourLight(TricolourLight input)
        {
            var result = _TricolourLight.DeleteByIdAsync(input);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateTricolourLight(TricolourLight input)
        {
            var result = _TricolourLight.PutUpdateTricolourLight(input);

            return result;
        }

        /// <summary>
        /// 修改(状态关闭)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> UpdateSelectTricol(TricolourLight input)
        {
            var result = _TricolourLight.UpdateSelectTricol(input);

            return result;
        }

        /// <summary>
        /// 修改(状态启动)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> UpdateSelectTricol1(TricolourLight input)
        {
            var result = _TricolourLight.UpdateSelectTricol1(input);

            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<TricolourLight>> GetTricolourLightAsync(fenye fenye)
        {
            var result = _TricolourLight.GetTricolourLightAsync(fenye);
            return result.Result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<TricolourLight> GetTricolourLightById(TricolourLight input)
        {
            var student = _TricolourLight.GetTricolourLightById(input);
            return student;
        }

        #endregion

        #region 三色灯日志


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<TricolourLightLog>> GetTricolourLightLog(SelectRizhi select)
        {
            var result = _TricolourLightLog.GetTricolourLightLogAsync(select);
            return result.Result;
        }

        /// <summary>
        /// 获取总条数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetCountRi()
        {
            return _TricolourLightLog.GetCount();
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteTricolourLightLog(TricolourLightLog input)
        {
            var result = _TricolourLightLog.DeleteByIdAsync(input);
            return result;
        }

        #endregion

        #region 大屏设备

        /// <summary>
        /// 获取总条数
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public int GetLargeScreenCount()
        {
            return _LargeScreen.GetCount();
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostLargeScreen(LargeScreen input)
        {
            var result = _LargeScreen.PostLargeScreen(input);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteLargeScreen(LargeScreen input)
        {
            var result = _LargeScreen.DeleteByIdAsync(input);
            return result;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutLargeScreen(LargeScreen input)
        {
            var result = _LargeScreen.PutLargeScreen(input);

            return result;
        }

        /// <summary>
        /// 修改(状态播放)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutLargeScreenStation(LargeScreen input)
        {
            var result = _LargeScreen.PutLargeScreenStation(input);

            return result;
        }

        /// <summary>
        /// 修改(状态关闭)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutLargeScreenStop(LargeScreen input)
        {
            var result = _LargeScreen.PutLargeScreenStop(input);

            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<LargeScreen>> GetLargeScreenAsync(LargeScreenInfo info)
        {
            var result = _LargeScreen.GetLargeScreenAsync(info);
            return result.Result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<LargeScreen> GetLargeScreenById(LargeScreen input)
        {
            var student = _LargeScreen.GetLargeScreenById(input);
            return student;
        }

        #endregion

        #region OLED大屏

        /// <summary>
        /// 添加OLED
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddOledScreen(OledScreen input)
        {
            var result = _oledScreenService.PostAddOledScreen(input);
            return result;
        }

        /// <summary>
        /// 删除OLED
        /// </summary>
        /// <param name="input"></param>
        [HttpDelete]
        public Task<Response<bool>> DeleteById(OledScreen input)
        {
            var result = _oledScreenService.DeleteByIdAsync(input);
            return result;
        }

        /// <summary>
        /// 修改OLED
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateOledScreen(OledScreen input)
        {
            var result = _oledScreenService.PutUpdateOledScreen(input);

            return result;

        }



        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public Response<List<OledScreen>> GetOledScreenAsync(formInline form)
        {
            var result = _oledScreenService.GetOledScreenAsync(form);
            return result.Result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<OledScreen> GetOledScreenById(OledScreen input)
        {
            var student = _oledScreenService.GetOledScreenById(input);
            return student;
        }

        /// <summary>
        /// 修改OLED状态启动
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateOledScreenTrue(OledScreen input)
        {
            var result = _oledScreenService.PutUpdateOledScreenTrue(input);
            return result;
        }

        /// <summary>
        /// 修改OLED状态关闭
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<Response<bool>> PutUpdateOledScreenFalse(OledScreen input)
        {
            var result = _oledScreenService.PutUpdateOledScreenFalse(input);
            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<List<OledScreenLog>> GetOledScreenLogAsync(formInline form)
        {
            var result = _oledScreenLogService.GetOledScreenLogAsync(form);
            return result.Result;
        }

        /// <summary>
        /// 删除OLED日志
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<Response<bool>> DeleteByIdLogAsync(OledScreenLog input)
        {
            var result = _oledScreenLogService.DeleteByIdAsync(input);
            return result;
        }

        /// <summary>
        /// 添加OLED日志
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<Response<bool>> PostAddOledScreenLog(OledScreenLog input)
        {
            var result = _oledScreenLogService.PostAddOledScreenLog(input);
            return result;
        }

        #endregion
    }
}
